import axios from "axios"
export default {
    namespaced: true,
    state: {
        arr:[]
    },
    mutations: {
        setArr(state,payload){
            state.arr = payload
        },
        // 表格的增加
        addFn(state,payload){
            state.arr.unshift(payload)
        },
        // 删除的方法  
        delFun(state,payload){
            state.arr.splice(payload,1)
        },
        editFn(state,payload){
            console.log(payload)
         state.arr[payload.index] = payload
        }
    },
    actions: {
        getArr({commit},payload){
           axios.get("/list").then(res=>{
                console.log(res.data)
                commit("setArr",res.data)
           })
        }
    },
}